<?php 
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
Header("Content-type: application/vnd.google-earth.kml+xml");
?>
<kml xmlns="http://earth.google.com/kml/2.1"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Document>
    <name><?php echo $data["track"]["description"]; ?></name>
    <Snippet>Created <?php print $data["track"]["time"]; ?></Snippet>
    <Folder>
      <name>Tracks</name>
      <Folder>
        <name><?php echo $data["track"]["description"]; ?></name>
        <Snippet/>
        <Placemark>
          <name>Track</name>
        <Style>
        <LineStyle><color>ff0000ff</color><width>4</width></LineStyle>
        <PolyStyle><color>7f00ff00</color></PolyStyle>
        </Style>
          <LineString>
            <coordinates>
<?php while ( list($id, $pointdata) = each ($data["coordinates"])): ?>
<?php printf("%.5f",$pointdata["lon"]); ?>,<?php printf("%.5f",$pointdata["lat"]); ?>

<?php endwhile; ?>


            </coordinates>
          </LineString>
        </Placemark>
      </Folder>
    </Folder>
  </Document>
</kml>
